<?php
class IndexAction extends Action
{
    public function index() {
    	
		$this->title = 'Hello Lnknear !';
		
		$this->display();
    	
    }
    
/*    public function checkEmail() {
    
    	if (!empty($_POST['email'])) {
			
			$User = D('User');
			
			//动态查询：getby字段名('字段值') --动态根据指定字段获取一条数据
			//基本查询方法：$User->where('字段名="值"')->find();
			
			if ($User->getByEmail($_POST['email'])) {
			
				$this->error('电子邮箱已经被注册');
			
			} else {
			
				$this->error('电子邮箱可以使用');
			
			}
		
		} else {
		
			$this->error('标题不能为空');
			
		}
		
    }*/
    
    // 检查标题是否可用 
    public function check() { 
        if(!empty($_POST['email'])) { 
            $Form    =    M("User"); 
            if($Form->getByTitle($_POST['email'])) { 
                $this->error('标题已经存在'); 
            }else{ 
                $this->success('标题可以使用!'); 
            } 
        }else{ 
            $this->error('标题必须'); 
        } 
    } 
    
    
	public function add() {
		
		$User = D('User');
		
		if(!$User->create()) {
			
			header("Content-Type:text/html; charset=utf-8");
			
			exit($User->getError().' [ <A HREF="javascript:history.back()">返 回</A> ]');
			
		}else{
		
			$User->add();
			
			//$this->redirect();
		
		}
	
	}
	
	public function login() {
	
		$User = D('User');
		
		if(!$User->login()) {
			
			header("Content-Type:text/html; charset=utf-8");
			
			exit($User->getError().' [ <A HREF="javascript:history.back()">返 回</A> ]');
			
		}else{
		
			$User->login();
			
			$this->redirect();
		
		}
		
	}

}
